package com.zbkj.common.response.device;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 设备响应对象
 * +----------------------------------------------------------------------
 * | 作者: xiaolic
 * +----------------------------------------------------------------------
 */
@Data
@ApiModel(value = "设备响应对象", description = "设备响应对象")
public class DeviceResponse {

    @ApiModelProperty(value = "请求状态码：1=成功")
    private String status;

    @ApiModelProperty(value = "响应数据")
    private Object data;

    /**
     * 构造成功响应
     * @param data 字符串数据
     * @return 成功响应
     */
    public static DeviceResponse success(String data) {
        DeviceResponse response = new DeviceResponse();
        response.setStatus("1");
        response.setData(data);
        return response;
    }
    
    /**
     * 构造成功响应（支持对象）
     * @param data 对象数据
     * @return 成功响应
     */
    public static DeviceResponse success(Object data) {
        DeviceResponse response = new DeviceResponse();
        response.setStatus("1");
        response.setData(data);
        return response;
    }

    /**
     * 构造失败响应
     * @param status 状态码
     * @return 失败响应
     */
    public static DeviceResponse fail(String status) {
        DeviceResponse response = new DeviceResponse();
        response.setStatus(status);
        response.setData(null);
        return response;
    }
}
